package edu.hunau.cxb19.oop.class30;

import org.junit.Test;

/**
 *
 *@author hb
 *
 * 2020-04-14 15:02:54
 */

public class ThreadDaemonTest {

	@Test
	public void test01() {
		Thread t1 = new Thread(() -> {
			for (int i = 0; i < 1000; i++) {
				System.out.println(Thread.currentThread().getName() +"[ "+Thread.currentThread().isDaemon() +" ]:i=" + i);
			}
		}, "   my-thread-01");
		//将t1设置为守护线程
		t1.setDaemon(true);
 		t1.start();
 		
 		//main线程调用
 		for (int i = 0; i < 10; i++) {
 			System.out.println(Thread.currentThread().getName() +"[ "+Thread.currentThread().isDaemon() +" ]:i=" + i);
		}
		 
	}
}
